package service

import (
	"aglaia/internal/model"
	"aglaia/pkg/app"
)

func (svc *Service) Categories(page, pageSize int) ([]model.Category, int, error) {
	return svc.dao.Categories(pageSize, app.GetPageOffset(page, pageSize))
}

type CreateCategoryRequest struct {
	Name string `json:"name"`
}

func (svc *Service) CreateCategory(category CreateCategoryRequest) error {
	return svc.dao.CreateCategory(category.Name)
}

type DeleteCategoryRequest struct {
	Id uint `json:"id"`
}

func (svc *Service) DeleteCategory(category DeleteCategoryRequest) error {
	return svc.dao.DeleteCategory(category.Id)
}
